import Vue from 'vue'
import Router from 'vue-router'

// 进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 路由数据
import routes from './routes'

Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: routes
})

router.beforeEach((to, from, next) => {
  // 进度条
  NProgress.start()
  // ...
  console.log('router beforeEach', to, from, next)
  next()
})

router.afterEach((to, from) => {
  // 进度条
  NProgress.done()
  // ...
  console.log('router afterEach', to, from)
})

export default router
